/**
 * 
 */
package neptune.web.client.view.components.dialogs;

import neptune.web.client.services.ApplicationDataProvider;
import neptune.web.client.view.input.DefaultInputValidator;
import neptune.web.client.view.input.EmailValidator;

import com.google.gwt.user.client.ui.ListBox;
import com.google.gwt.user.client.ui.TextBox;

/**
 * @author Roberto Bifulco [info@robertobifulco.it, robertobifulco.it]
 * 
 */
public class UserDetailsDialog extends PropertiesDialog {

	public static String USERNAME = "Username";
	public static String PASSWORD = "Password";
	public static String ROLE = "Role";
	public static String EMAIL = "e-Mail";
	
	
	public UserDetailsDialog() {
		super(null);
		this.setText("User Details Window");
		TextBox usrname = new TextBox();
		usrname.setEnabled(false);
		this
				.addProperty(USERNAME, usrname,
						new DefaultInputValidator());
		this
				.addProperty(PASSWORD, new TextBox(),
						new DefaultInputValidator());

		final ListBox list = new ListBox();

		// Recupera le informazioni sui ruoli degli utenti definiti
		String[] roles = ApplicationDataProvider.getInstance().getUserRoles();
		for (int i = 0; i < roles.length; i++) {
			list.addItem(roles[i]);
		}
		
/* Questa parte di codice e' il vecchio modo in cui venivano recuperati i dati
   riguardanti i ruoli definiti sul sistema. Perche' funzioni e' necessario
   introdurre nuovamente il metodo getUsersInfo in UserService.
*/
//		UserService.Util.getInstance().getUsersInfo(new AsyncCallback() {
//
//			public void onSuccess(Object arg0) {
//				String[] roles = ((ApplicationGenericInfo)arg0).getDefinedRoles(); 
//				for (int i = 0; i < roles.length; i++) {
//					list.addItem(roles[i]);
//				}
//			}
//
//			public void onFailure(Throwable arg0) {
//				ConsoleManager.addConsoleMessage(
//						"Async comunication error in retriving users'roles: "
//								+ arg0.getMessage(), true);
//			}
//
//		});

		this.addProperty(ROLE, list);
		
		this.addProperty(EMAIL, new TextBox(), new EmailValidator());
	}
}
